﻿using System;
using System.Threading.Tasks;

namespace Jack.RedisEventBus.WebApiDemo.EventBus
{
    public class OrderEventHandler : IEventHandle<OrderEvent>
    {
        static Random rnd = new Random();

        public Task EventHandle(EventData eventData)
        {
            if (rnd.Next(0, 5) % 5 == 0) throw new NotImplementedException();

            Console.WriteLine((string)eventData);
            OrderEvent orderEvent = eventData.ConvertData<OrderEvent>();
            Console.WriteLine($"{orderEvent.OrderNo}");

            return Task.CompletedTask;
        }
    }
}
